//
//  DateformateShared.m
//  huashiedu
//
//  Created by oceans on 2018/9/5.
//  Copyright © 2018年 hema. All rights reserved.
//

#import "DateformateShared.h"

static DateformateShared *shared;
@implementation DateformateShared

+ (instancetype)shared {
    static dispatch_once_t token;
    dispatch_once(&token, ^{
        shared = [[DateformateShared alloc] init];
    });
    return shared;
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone {
    static dispatch_once_t token;
    dispatch_once(&token, ^{
        shared = [super allocWithZone:zone];
    });
    return shared;
}

- (id)copyWithZone:(NSZone*)zone {
    return shared;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        _dateformate = [[NSDateFormatter alloc] init];
        [_dateformate setDateFormat:@"yyyyMMddHHmmss"];
    }
    return self;
}

- (NSString *)timeintervalToString:(NSTimeInterval)time {
    
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:time];
    return [_dateformate stringFromDate:date];
}

@end
